﻿@model Web.Models.MovieListViewModel

@if (Model != null)
    {
            <div style="text-align:center">

            @if (Model.Size == MovieListViewModel.SizeBig)
            {
                foreach (MovieViewModel movie in Model.movies)
                {
                    <div class="movieListItem">
                    @if (movie != null && movie.Movie != null && movie.Movie.Files != null)
                    {
                            <img class="cover" src='@String.Format("http://{0}/Uploads/{1}", Request.Url.Host, movie.Movie.Files.FileUrl)' alt="cover" />
                    }
                    else
                    {
                              <img class="cover" src='@String.Format("http://{0}/Uploads/movie_unknown.jpg", Request.Url.Host)' alt="cover" />
                    }

                    <div class="movieDescription">
                        <h3>@movie.Movie.MovieTitle</h3>
                        <div class="row"><label class="headerCell" id="movieDirector">Reżyser:</label><label class="contentCell">@movie.Movie.MovieDirector</label></div>
                        <div class="row"><label class="headerCell" id="movieProducer">Produkcja:</label><label class="contentCell">@movie.Movie.MoviePublisher</label></div>
                        <div class="row"><label class="headerCell" id="movieIssueDate">Data wydania:</label><label class="contentCell">@movie.Movie.MovieIssueDate.ToString("MMMM yyyy")</label></div>
                        <div class="row"><label class="headerCell" id="movieDuration">Czas trwania:</label><label class="contentCell">@movie.Movie.MovieDuration min</label></div>
                        @if (movie.SelectedKinds != null)
                        {
                            <div class="row">
                            <label class="headerCell" id="movieKind">Gatunek:</label>
                            <label class="contentCell">
                                @foreach (MovieKinds item in movie.SelectedKinds)
                                {
                                    <label>@item.MovieKindName</label>
                                }
                            </label>
                            </div>
                        }
                    </div>

                    <a id="movieInfoButton" class="movieButton" href='@String.Format("http://{0}/movie/{1}/details", Request.Url.Host, movie.Movie.MovieGuid)' title="Szczegóły"></a>
                    @if (ViewBag.IsCustomerLogged)
                    {
                        <a id="movieRentButton" class="movieButton" href='@String.Format("http://{0}/movie/{1}/copies", Request.Url.Host, movie.Movie.MovieGuid)' title="Wypożycz"></a>
                    }
                </div>
                }
            }
            else
            {
                <table class="list">
                <thead>
                    <tr>
                        <td>Tytuł</td>
                        <td>Reżyser</td>
                        <td>Wydawca</td>
                        <td>Produkcja</td>
                        <td>Udostępniono</td>
                        <td></td>
                    </tr>
                </thead>

                @foreach (Web.Models.MovieViewModel movie in Model.movies)
                {
                     <tr>
                        <td>@movie.Movie.MovieTitle</td>
                        <td>@movie.Movie.MovieDirector</td>
                        <td>@movie.Movie.MoviePublisher</td>
                        <td>@movie.Movie.MovieIssueDate.ToString("MMMM yyyy")</td>
                        <td>@movie.Movie.MovieAddedDate.ToString("dd.MM.yyyy")</td>
                        <td>@Html.ActionLink("Szczegóły", "Details", new { guid = movie.Movie.MovieGuid })</td>
                     </tr>
                }

            </table>
            }
        
            </div>
            
        if (Model.PagingInfo != null)
        {
            <div class="pagesNavigation">
                @Html.PageLinks(Model.PagingInfo, x => Url.Action("Index", new { kindId = Model.SelectedKind, size = Model.Size, movieItemOrder = Model.SortBy, orderDirection = Model.ListDirection, page = x }))
            </div>
        }
    }